package com.incar.chuxing.utils;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * Created by Michael Pi on 2016/10/14.
 */
public class CheckRegexUtils {
    public static boolean checkPhoneNum(String str) {
        String regexp = "^1[3|4|5|7|8]\\d{9}$";
        Pattern pattern = Pattern.compile(regexp);
        Matcher matcher = pattern.matcher(str);
        return matcher.matches();
    }

    public static boolean checkPassword(String str) {
        String regexp = "^[a-zA-Z0-9]{6,16}$";
        Pattern pattern = Pattern.compile(regexp);
        Matcher matcher = pattern.matcher(str);
        return matcher.matches();
    }

    public static boolean checkIdCard(String str) {
        String regexp = "(^[1-9]\\d{5}(18|19|([23]\\d))\\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\\d{3}[0-9Xx]$)|(^[1-9]\\d{5}\\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\\d{3}$)\n";
        Pattern pattern = Pattern.compile(regexp);
        Matcher matcher = pattern.matcher(str);
        return (matcher.matches());
    }

    public static boolean checkQRCode(String str) {
        String regexp = "([0-9]+)";
        Pattern pattern = Pattern.compile(regexp);
        Matcher matcher = pattern.matcher(str);
        return (matcher.matches());
    }

}